"""author: songzhiqiang
   data: 2021/11/24
   project: zuoye2
"""
import os
p = input("网段：")
with open("ip.txt","w+") as f:
        for i in range(1,255):
                ip = p + "." + str(i)
                try:
                        re = os.system(f"ping {ip} -c 1 &>/dev/null")
                        print(re)
                        if re == 0:
                                f.write(f"{ip}已被使用！\n")
                        else:
                                f.write(f"{ip}未被使用！\n")
                except:
                        print(f"{ip}出现异常")
